package com.autumn.workflow.command.task;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.autumn.platform.dao.annotation.Execute;
import com.autumn.platform.dao.annotation.Executes;
import com.autumn.workflow.model.UserTaskFlow;
import com.autumn.workflow.model.UserTaskNode;

@Mapper
public interface UserTaskRepository {

    @Executes({@Execute(sqlRef = "deleteTaskNode", batch = false), //删除任务节点定义
            @Execute(sqlRef = "insertTaskNode", property = "nodes"), //添加任务节点定义
            @Execute(sqlRef = "deleteTaskFlow", batch = false), //删除任务路径定义
            @Execute(sqlRef = "insertTaskFlow", property = "flows")//添加任务路径定义
    })
    int[] initializeTaskNodeAndFlow(@Param("procDefId") String procDefId, @Param("nodes") List<UserTaskNode> nodes, @Param("flows") List<UserTaskFlow> flows);

    /**
     * 查询所有可能的下一任务节点
     * 
     * @param param
     * @return
     */
    List<UserTaskNode> queryNextPossibleUserTaskNodes(UserTaskFlow param);

    /**
     * 查询任务流
     * 
     * @param param
     * @return
     */
    UserTaskFlow queryUserTaskFlow(UserTaskFlow param);

    /**
     * 更新节点信息
     * 
     * @param procInstId
     * @param srcTaskKey
     * @param destTaskKey
     */
    void updateHistoryActivity(@Param("procInstId") String procInstId, @Param("srcTaskKey") String srcTaskKey, @Param("destTaskKey") String destTaskKey);
}
